home *** CD-ROM | disk | FTP | other *** search
- Path: news.mel.aone.net.au!usenet
- From: clyde@hitech.com.au (Clyde Smith-Stubbs)
- Newsgroups: comp.lang.c
- Subject: Re: Floating point calculation order
- Date: Thu, 25 Jan 1996 06:27:55 GMT
- Organization: HI-TECH Software
- Message-ID: <310721ca.60354688@news.bne.aone.net.au>
- References: <m0tedv8-0002eqC@sice.nsk.su> <3104c6d9.134061184@nntp.ix.netcom.com> <DLnE5K.2xH@microunity.com> <mjs.822427333@hubcap>
- Reply-To: clyde@hitech.com.au
- NNTP-Posting-Host: skyhawk.hitech.com.au
- X-Newsreader: Forte Agent .99c/16.141
-
- On 23 Jan 96 20:02:13 GMT, mjs@hubcap.clemson.edu (M. J. Saltzman)
- wrote:
-
- >Would somebody explain under exactly what circumstances an ANSI
- >compiler is and is not allowed to reorder evaluation? My recollection
-
- Basically the compiler will honour operator precedence and
- associativity. The * and / are both left-associative and of
- equal precedence, so the * gets done first in a * b / c.
-
- Of course there's always the "as-if" rule, meaning the compiler is
- actually free to generate whatever code it likes, as long as it
- behaves "as-if" it was executed according to the rules of the abstract
- machine defined by the standard. So it is quite alright for a compiler
- to reorder a * b * c since the result will be the same, but not a * b
- / c since the result will be different if the / is done first.
-
- ----
- Clyde Smith-Stubbs | HI-TECH Software, | Voice: +61 7 3300 5011
- clyde@hitech.com.au | P.O. Box 103, Alderley, | Fax: +61 7 3300 5246
- http://www.hitech.com.au | QLD, 4051, AUSTRALIA. | BBS: +61 7 3300 5235
- ----------------------------------------------------------------------------
- FREE! Download our shareware (FREE for noncommercial use) MS-DOS C Compiler!
- Point your Web browser at http://www.hitech.com.au/
-